package chapter1.No1_9_yield方法;

/**
 * yield：放弃当前CPU的资源
 *
 * @author liujian
 * @version 2016/11/10 0010
 */
public class MyThread extends Thread {

    @Override
    public void run() {
        long startTime = System.currentTimeMillis();
        int count = 0;
        for (int i = 0; i < 1000000; i++) {
//            Thread.yield();
            count = count + i;
        }
        long endTime = System.currentTimeMillis();
        System.out.println("耗时：" + (endTime - startTime) + "毫秒");
    }

    public static void main(String[] args) {
        MyThread m1 = new MyThread();
        m1.start();
    }

}
